﻿using System;
using System.Collections.Generic;

namespace KuiHuaBaoDian {

    public interface IDataValue : IComparable<IDataValue>, IEquatable<IDataValue> {

        public enum RoundingMode {
            Up,
            Down,
            HalfUp,
            HalfDown,
            HalfEven
        }

        float Float { get; }

        int Int { get; }

        IDataValue Add(IDataValue right);
        IDataValue Subtract(IDataValue right);
        IDataValue Multiply(IDataValue right);
        IDataValue Divide(IDataValue right);

        IDataValue Pow(IDataValue right);

        IDataValue Ceil();
        IDataValue Floor();
        IDataValue Round();

        string ToString(string format);
        string ToAbbreviatedString(RoundingMode roundingMode = RoundingMode.HalfUp, int decimals = 2);
    }

    public static class DataValueExtensions {
        public static IDataValue Sum<TSource>(this IEnumerable<TSource> source, Func<TSource, IDataValue> selector) {
            IDataValue result = null;
            foreach (var item in source) {
                var value = selector(item);
                result = result == null ? value : result.Add(value);
            }
            return result;
        }
    }

    public interface IDataVector2 {
    }

    public interface IDataVector3 {
    }
}
